package com.maiji.cloud.entities.shopingmall;

import com.baomidou.mybatisplus.annotations.*;
import com.gitee.sunchenbin.mybatis.actable.annotation.Column;
import com.gitee.sunchenbin.mybatis.actable.annotation.Table;
import com.gitee.sunchenbin.mybatis.actable.constants.MySqlTypeConstant;
import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.experimental.Accessors;
import java.io.Serializable;
import java.util.Date;

/**
 *  商品表
 */
@NoArgsConstructor
@Data
@Accessors(chain=true)
@Table(name = "goods")
public class Goods implements Comparable<Goods> {

    @TableId
    @Column(name = "uu_id", type = MySqlTypeConstant.VARCHAR, length = 50, isKey = true)
    private String uuId;

    @Column(name = "name", type = MySqlTypeConstant.VARCHAR)
    private String name;  // 商品名称

    @Column(name = "short_name", type = MySqlTypeConstant.VARCHAR, length = 50)
    private String shortName;  // 商品简称

    @Column(name = "net_weight", type = MySqlTypeConstant.INT, length = 2, defaultValue = "0")
    private Integer netWeight;  // 净含量

    @Column(name = "weight", type = MySqlTypeConstant.INT, length = 2, defaultValue = "0")
    private Integer weight;  // 总重量(克)

    @Column(name = "original_price", type = MySqlTypeConstant.DOUBLE, length = 5, decimalLength = 2, defaultValue = "0.00")
    private Double originalPrice;  // 商品原价格

    @Column(name = "present_price", type = MySqlTypeConstant.DOUBLE, length = 5, decimalLength = 2, defaultValue = "0.00")
    private Double presentPrice;  // 商品现价格

    @Column(name = "stock_volume", type = MySqlTypeConstant.INT, length = 2, defaultValue = "0")
    private Integer stockVolume; // 库存

    @Column(name = "sales_volume", type = MySqlTypeConstant.INT, length = 2, defaultValue = "0")
    private Integer salesVolume; // 销售量

    @Column(name = "collection_volume", type = MySqlTypeConstant.INT, length = 2, defaultValue = "0")
    private Integer collectionVolume; // 收藏数

    @Column(name = "comment_volume", type = MySqlTypeConstant.INT, length = 2, defaultValue = "0")
    private Integer commentVolume; // 评论数

    @Column(name = "comment_count", type = MySqlTypeConstant.INT, length = 2, defaultValue = "0")
    private Integer commentCount; // 未审核评论数

    @Column(name = "is_exchange", type = MySqlTypeConstant.INT, length = 1)
    private Integer isExchange; // 是否可积分兑换：1是，0否

    @Column(name = "integral", type = MySqlTypeConstant.INT, length = 1, defaultValue = "0")
    private Integer integral; // 积分兑换值

    @Column(name = "update_date", type = MySqlTypeConstant.DATETIME)
    private Date updateDate; // 变更时间

    @Column(name = "up_down", type = MySqlTypeConstant.INT, length = 1, defaultValue = "1")
    private Integer upDown; // 1-上架，2-下架

    @Column(name = "up_date", type = MySqlTypeConstant.DATETIME)
    private Date upDate; // 上架时间

    @Column(name = "down_date", type = MySqlTypeConstant.DATETIME)
    private Date downDate; // 下架时间

    @Column(name = "detail_text", type = MySqlTypeConstant.TEXT)
    private String detailText;  // 商品详情

    @Column(name = "sort_weight", type = MySqlTypeConstant.INT, length = 2, defaultValue = "0")
    private Integer sortWeight; // 排序权重

    @TableLogic
    @Column(name = "is_del", type = MySqlTypeConstant.INT, length = 1, defaultValue = "0")
    private Integer isDel; //是否删除：1删除，0未删除

    @Column(name = "del_date", type = MySqlTypeConstant.DATETIME)
    private Date delDate; // 删除时间

    @Version
    @Column(name = "version", type = MySqlTypeConstant.INT, length = 1, defaultValue = "0")
    private Integer version; // 数据版本号

    @Override
    public int compareTo(Goods goods) {
        return goods.getSortWeight() - this.getSortWeight();
    }

}
